# -*- coding: utf-8 -*-
def reverse(n):
    strn = list(str(n))
    strn.reverse()
    return int(''.join(strn))

def panduan(n):
    jishu = ['1','3','5','7','9']
    strn = list(str(n))
    for x in strn:
        if x in jishu:
            continue
        else:
            return 0
    return 1

kefanshu = set()

def jia(n):
    global count
    b = reverse(n)
    c = n + b
    if panduan(c):

        kefanshu.add(n)
        kefanshu.add(b)
##        print a,b,c
def main():
    global kefanshu
    jishu = [2,4,6,8,0]
    for x in xrange(10,100000001):
        if x in kefanshu:
            continue
        strx = list(str(x))
        if strx[-1] == '0':
            continue
        if len(strx) == 5 or len(strx) == 1 or len(strx) == 9:
            continue
        if strx[0] == strx[-1]:
            continue
        yushu = (int(strx[0]) + int(strx[-1])) % 10
        if yushu  in jishu:
            continue
        jia(x)
    print len(kefanshu)

if __name__ == '__main__':
##    608720
##Execution time: 782.443000078 seconds
    import time
    start = time.time()
    main()
    print('Execution time: {0} seconds'.format(time.time() - start))
